package task1;

import java.util.Scanner;

public class GuessGame {

    public static void start() {
    /*
    1.产生随机数
    2.循环：
        接受输入
        判断：提示大于，小于
                猜中，提示并退出
     */

    int random= (int) (Math.random()*1000+1);
    int guess=-1;
        while (guess!=random) {
            System.out.println("请输入猜测的数字：（1-1000）：");
            Scanner scanner=new Scanner(System.in);
            guess=scanner.nextInt();
            if(guess>random){
                System.out.println("大了");
            }else if(guess<random){
                System.out.println("小了");
            }else {
                System.out.println("猜中了");
                break;
            }

        }
    }
}
